define(['jquery'],function($){
	var ajaxRequest={
		getRequest:function(option,callBack){
			$.ajax({
			    type: 'GET',
			    url: option,
			    dataType: 'json',
			    timeout: 3000,
			    success: function(response){
	            	callBack(response);
	            },
	            error:function(xhr){
	            }
			})
		},
		getValidateImg:function(url){
			$.getJSON(url, {}, function(json) {
		        $('.validate').removeClass('hide');
		        $('.validateImg img').attr('src',json.image_url);
		        $('#id_captcha_0').val(json.key);
		    });
		},
		postRequest:function(option,errorInfo,callBack){
			// using jQuery
			function getCookie(name) {
			    var cookieValue = null;
			    if (document.cookie && document.cookie != '') {
			        var cookies = document.cookie.split(';');
			        for (var i = 0; i < cookies.length; i++) {
			            var cookie = jQuery.trim(cookies[i]);
			            // Does this cookie string begin with the name we want?
			            if (cookie.substring(0, name.length + 1) == (name + '=')) {
			                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
			                break;
			            }
			        }
			    }
			    return cookieValue;
			}
			var csrftoken = getCookie('csrftoken');
			$.ajax({
	            type: 'POST',
	            url: option.url,
	            data: option.datas,
	            dataType: 'json',
	            timeout: 3000,
	            beforeSend: function(xhr, settings) {
			        if (!this.crossDomain) {
			            xhr.setRequestHeader("X-CSRFToken", csrftoken);
			        }
			    },
	            success: function(response){
	            	callBack(response);
	            },
	            error:function(xhr){
	            }
	        })
		}
	}
	return ajaxRequest;
})